package javabase.biji;

/**
 * @Auther: luzhanshi
 * @Date: 2021/2/2 - 02 - 02 - 17:20 
 * @Description: javabase.biji
 * @version: 1.0
 */
public class _32可变参数 {
    public static void main(String[] args) {
        System.out.println(getSum(1,2,3,4));
        getSum2("a","b","c");
    }
    public static int getSum(int ...num){
        System.out.println(num);//
        int sum=0;
        for (int i:num){
            sum+=i;
        }
        return sum;
    }

    public static int getSum2(int a,int ...num){//一个方法如果有多个参数并且包含可变参数,可变参数要放在最后,不然后面的参数获取不到值
        return 0 ;
    }

    public static void getSum2(String ... strings){
        for (String string : strings) {
            System.out.println(string);
        }
    }
}
